from PySide6.QtWidgets import QWidget, QVBoxLayout
from view.components.dialog_widget import DialogWidget
from view.components.toast_widget import ToastWidget
from core import bus

class BaseModule(QWidget):
    """所有功能模块的基类"""
    need_server_widget = True
    DialogWidget = DialogWidget
    ToastWidget = ToastWidget
    bus = bus

    def __init__(self, parent=None):
        super().__init__(parent)
        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(0, 8, 0, 0)
        self.layout.setSpacing(8)
        self.init_ui()

    def init_ui(self):
        """初始化界面，子类需要重写此方法"""
        pass

    def on_activate(self):
        """当模块被激活时调用"""
        pass

    def on_deactivate(self):
        """当模块被切换出去时调用"""
        pass
